package com.nbsaas.boot.room.rest.resource;

import com.nbsaas.boot.room.api.apis.RoomApi;
import com.nbsaas.boot.room.data.entity.Room;
import com.nbsaas.boot.room.api.domain.request.RoomRequest;
import com.nbsaas.boot.room.api.domain.response.RoomResponse;
import com.nbsaas.boot.room.api.domain.simple.RoomSimple;
import com.nbsaas.boot.room.rest.convert.RoomSimpleConvert;
import com.nbsaas.boot.room.rest.convert.RoomEntityConvert;
import com.nbsaas.boot.room.rest.convert.RoomResponseConvert;
import com.nbsaas.boot.room.data.repository.RoomRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   业务接口实现
*/
@Transactional
@Service
public class RoomResource extends BaseResource<Room,RoomResponse, RoomSimple, RoomRequest>  implements RoomApi {

    @Resource
    private RoomRepository roomRepository;

    @Override
    public JpaRepositoryImplementation<Room, Serializable> getJpaRepository() {
        return roomRepository;
    }

    @Override
    public Function<Room, RoomSimple> getConvertSimple() {
        return new RoomSimpleConvert();
    }

    @Override
    public Function<RoomRequest, Room> getConvertForm() {
        return new RoomEntityConvert();
    }

    @Override
    public Function<Room, RoomResponse> getConvertResponse() {
        return new RoomResponseConvert();
    }




}


